package 队列.linkedblockedqueue;

import java.util.concurrent.LinkedBlockingQueue;

import 集合相关.queue.LinkedBlockingQueue_Demo;

public class WorkThread extends Thread{
	private Object obj=new Object();
	private LinkedBlockingQueue<Integer> lbq=new LinkedBlockingQueue<Integer>();

	private DataCallback mCallBack;
	public void init(DataCallback callback){
		this.mCallBack=callback;
		obj.notify();
	}
	public void add( Integer i){
		lbq.offer(i);
	}
	@Override
	public void run() {
		super.run();
		try {
			Thread.sleep(500);
			Integer value=-1;
			while(true){
				value=this.lbq.take();
				if(value>0){
					synchronized (obj) {
						if(mCallBack==null){
							this.wait();
						}
					}
					this.lbq.offer(value);
				}
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

}
